﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using SQLExecute;

public partial class mail_history_sendmail : System.Web.UI.Page
{

    DataSet ds;
    string sql;

    protected void Page_Init(object sender, EventArgs e)
    {
       // if (!IsPostBack)
            BindGrid();
    }


    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["username"] == null && Session["fullname"] == null)
                Response.Redirect("../login/login.aspx");
            else
            {
                lUsername.Text = " " + Session["username"].ToString();
                BindGrid();
                gdListProfilesRejected.Columns[0].Visible = false;
                
            }


        }
    }
    protected void gdListProfilesRejected_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
    {
        e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#f7f7f7';");
        if ((e.VisibleIndex % 2) == 0)
        {
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white';");
        }
        else
        {
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white';");
        }
    }
    protected void lnkLogout_Click(object sender, EventArgs e)
    {
        //FormsAuthentication.SignOut();

        Session.Clear();
        Response.Redirect("../login/login.aspx");
    }
    protected void BindGrid()
    { 
        //sql="select * from tbl_sendmail_info order by date_sended desc";
        
        if (txtFrom.Text!="" && txtTo.Text!="")
        {
            DateTime f,t;
            f=DateTime.Parse(Common.Convert_DDMMYYYY_To_MMDDYYY(txtFrom.Text));
            t=DateTime.Parse(Common.Convert_DDMMYYYY_To_MMDDYYY(txtTo.Text));
            ds = SqlHelper.ExecuteDataset(Common.strConnect, "Get_List_Mail_Sended", new object[]{f,t});
            
        }
        else
            ds = SqlHelper.ExecuteDataset(Common.strConnect, "Get_List_Mail_Sended", new object[]{null,null });
        gdListProfilesRejected.DataSource = ds;
        gdListProfilesRejected.DataBind();

    }
    protected void btnView_Click(object sender, EventArgs e)
    {
        BindGrid();

    }
   
}
